package com.hibuy.pc.service.shiro.impl;

import com.hibuy.pc.mapper.shiro.UserMapper;
import com.hibuy.pc.model.shiro.User;
import com.hibuy.pc.model.shiro.UserRole;
import com.hibuy.pc.service.shiro.UserRoleService;
import com.hibuy.pc.service.shiro.UserService;
import com.hibuy.pc.util.ThreadPoolUtil;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by admin on 2017/12/28.
 */
@Service
public class UserServiceImpl implements UserService {

    private Logger logger = Logger.getLogger(UserServiceImpl.class);

    @Autowired
    private UserMapper userMapper;

    @Autowired
    private UserRoleService userRoleService;

    @Override
    public List<User> findUserList() {
        return userMapper.findUserList();
    }

    @Override
    public void addUser(User user, Integer roleId) {
        Integer userId = userMapper.addUser(user).getId();
        UserRole userRole = new UserRole();
        userRole.setuId(userId);
        userRole.setrId(roleId);
        userRoleService.addUserRole(userRole);
    }

}
